/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ItemDescription.java
 *
 * Created on Apr 4, 2011, 12:18:00 AM
 */

package GUI;

import Controller.POSController;
import Entities.Item;

/**
 *
 * @author Spence
 */
public class ItemDescription extends javax.swing.JPanel {

    private POSController controller;
    private Item item;

    /** Creates new form ItemDescription */
    public ItemDescription(POSController control, Item selection) {
        initComponents();
        controller = control;
        item = selection;
        customInit();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        FieldsPanel = new javax.swing.JPanel();
        NameField = new javax.swing.JTextField();
        UPCField = new javax.swing.JTextField();
        MakeField = new javax.swing.JTextField();
        ModelField = new javax.swing.JTextField();
        PriceField = new javax.swing.JTextField();
        DescriptionPane = new javax.swing.JScrollPane();
        DescriptionField = new javax.swing.JTextArea();
        LabelPanel = new javax.swing.JPanel();
        NameLabel = new javax.swing.JLabel();
        MakeLabel = new javax.swing.JLabel();
        ModelLabel = new javax.swing.JLabel();
        PriceLabel = new javax.swing.JLabel();
        DescriptionLabel = new javax.swing.JLabel();
        UPCLabel = new javax.swing.JLabel();
        AddButton = new javax.swing.JButton();
        QtySelect1 = new javax.swing.JComboBox();

        setBackground(new java.awt.Color(255, 255, 255));
        setBounds(new java.awt.Rectangle(0, 0, 650, 500));
        setMaximumSize(new java.awt.Dimension(650, 500));

        FieldsPanel.setBackground(new java.awt.Color(255, 255, 255));

        NameField.setFont(new java.awt.Font("Tahoma", 0, 14));

        UPCField.setFont(new java.awt.Font("Tahoma", 0, 14));

        MakeField.setFont(new java.awt.Font("Tahoma", 0, 14));

        ModelField.setFont(new java.awt.Font("Tahoma", 0, 14));

        PriceField.setFont(new java.awt.Font("Tahoma", 0, 14));

        DescriptionField.setColumns(20);
        DescriptionField.setRows(5);
        DescriptionPane.setViewportView(DescriptionField);

        org.jdesktop.layout.GroupLayout FieldsPanelLayout = new org.jdesktop.layout.GroupLayout(FieldsPanel);
        FieldsPanel.setLayout(FieldsPanelLayout);
        FieldsPanelLayout.setHorizontalGroup(
            FieldsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(FieldsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(FieldsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(ModelField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                    .add(MakeField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                    .add(UPCField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                    .add(NameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                    .add(PriceField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                    .add(DescriptionPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)))
        );
        FieldsPanelLayout.setVerticalGroup(
            FieldsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(FieldsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(NameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(UPCField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(MakeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(ModelField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(PriceField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(DescriptionPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        LabelPanel.setBackground(new java.awt.Color(255, 255, 255));

        NameLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        NameLabel.setText("Name");

        MakeLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        MakeLabel.setText("Make");

        ModelLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        ModelLabel.setText("Model");

        PriceLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        PriceLabel.setText("Price");

        DescriptionLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        DescriptionLabel.setText("Description");

        UPCLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        UPCLabel.setText("UPC");

        org.jdesktop.layout.GroupLayout LabelPanelLayout = new org.jdesktop.layout.GroupLayout(LabelPanel);
        LabelPanel.setLayout(LabelPanelLayout);
        LabelPanelLayout.setHorizontalGroup(
            LabelPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(LabelPanelLayout.createSequentialGroup()
                .add(62, 62, 62)
                .add(NameLabel)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, LabelPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(DescriptionLabel)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, LabelPanelLayout.createSequentialGroup()
                .addContainerGap(70, Short.MAX_VALUE)
                .add(PriceLabel)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, LabelPanelLayout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .add(MakeLabel)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, LabelPanelLayout.createSequentialGroup()
                .addContainerGap(74, Short.MAX_VALUE)
                .add(UPCLabel)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, LabelPanelLayout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .add(ModelLabel)
                .addContainerGap())
        );
        LabelPanelLayout.setVerticalGroup(
            LabelPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(LabelPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(NameLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 28, Short.MAX_VALUE)
                .add(UPCLabel)
                .add(27, 27, 27)
                .add(MakeLabel)
                .add(27, 27, 27)
                .add(ModelLabel)
                .add(18, 18, 18)
                .add(PriceLabel)
                .add(26, 26, 26)
                .add(DescriptionLabel)
                .addContainerGap())
        );

        AddButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        AddButton.setText("Add to Cart");
        AddButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddButtonActionPerformed(evt);
            }
        });

        QtySelect1.setFont(new java.awt.Font("Tahoma", 0, 18));
        QtySelect1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select Quantity", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(9, 9, 9)
                .add(LabelPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(QtySelect1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(37, 37, 37)
                        .add(AddButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 154, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, FieldsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(40, 40, 40))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(LabelPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(FieldsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(AddButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 83, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(QtySelect1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .add(21, 21, 21))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddButtonActionPerformed
        // TODO add your handling code here:
        controller.addItemToCart(item);
        controller.CartScreen();
    }//GEN-LAST:event_AddButtonActionPerformed
    
    private void customInit(){
        NameField.setText(item.getItemName());
        MakeField.setText(item.getMake());
        ModelField.setText(item.getModel());
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddButton;
    private javax.swing.JTextArea DescriptionField;
    private javax.swing.JLabel DescriptionLabel;
    private javax.swing.JScrollPane DescriptionPane;
    private javax.swing.JPanel FieldsPanel;
    private javax.swing.JPanel LabelPanel;
    private javax.swing.JTextField MakeField;
    private javax.swing.JLabel MakeLabel;
    private javax.swing.JTextField ModelField;
    private javax.swing.JLabel ModelLabel;
    private javax.swing.JTextField NameField;
    private javax.swing.JLabel NameLabel;
    private javax.swing.JTextField PriceField;
    private javax.swing.JLabel PriceLabel;
    private javax.swing.JComboBox QtySelect1;
    private javax.swing.JTextField UPCField;
    private javax.swing.JLabel UPCLabel;
    // End of variables declaration//GEN-END:variables

}
